/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */
#ifndef __ADT__
#define __ADT__

#include "NgPrerequisites.h"

#define	MCLY_USE_ALPHAMAP		0x100
#define	MCLY_ALPHAMAP_COMPRESS	0x200

namespace PQGame
{
	typedef struct _adt_mhdr{
		unsigned int flags;		// &1: MFBO, &2: unknown. in some Northrend ones.
		unsigned int mcin;		
		unsigned int mtex;		
		unsigned int mmdx;
		unsigned int mmid;		
		unsigned int mwmo;
		unsigned int mwid;		
		unsigned int mddf;
		unsigned int modf;	
		unsigned int mfbo; 		// tbc, wotlk; only when flags&1
		unsigned int mh2o;		// wotlk
		unsigned int mtfx;		// wotlk
		unsigned int pad4;		
		unsigned int pad5;		
		unsigned int pad6;		
		unsigned int pad7;	
	}adt_mhdr;

	typedef struct _adt_mcin{
		int offset;
		int size;
		int unused_flags;
		int unused_id;
	}adt_mcin;

	typedef struct _adt_mddf
	{
		unsigned int nameId;
		unsigned int uniqueId;
		float pos[3];		
		float rot[3];
		unsigned short scale;
		unsigned short flags;
	}adt_mddf;

	typedef struct _adt_modf
	{
		unsigned int nameId;
		unsigned int uniqueId;
		float pos[3];
		float rot[3];
		float extents[6];
		unsigned short flags;
		unsigned short doodadSetIndex;
		unsigned short nameSet;
		unsigned short pad; 
	}adt_modf; 


	/*
	MCNK chunk
	http://www.madx.dk/wowdev/wiki/index.php?title=ADT/v18
	After the above mentioned chunks come 256 individual MCNK chunks, row by row, starting from top-left (northwest). The MCNK chunks have a large block of data that starts with a header, and then has sub-chunks of its own.
	Each map chunk has 9x9 vertices, and in between them 8x8 additional vertices, several texture layers, normal vectors, a shadow map, etc.
	The MCNK header is 128 bytes large.
	*/
	typedef struct _map_chunk_header {
		unsigned int flags;
		unsigned int index_x;
		unsigned int index_y;
		unsigned int nLayers;//maximum 4
		unsigned int nDoodadRefs;
		unsigned int ofsHeight; // MCVT
		unsigned int ofsNormal; // MCNR
		unsigned int ofsLayer; // MCLY
		unsigned int ofsRefs; // MCRF
		unsigned int ofsAlpha; // MCAL
		unsigned int sizeAlpha;
		unsigned int ofsShadow; // MCSH
		unsigned int sizeShadow;
		unsigned int areaid;
		unsigned int nMapObjRefs;
		unsigned int holes;
		unsigned short s1; // UINT2[8][8] ReallyLowQualityTextureingMap;	// the content is the layer being on top, I guess.
		unsigned short s2;
		unsigned int d1;
		unsigned int d2;
		unsigned int d3;
		unsigned int predTex;
		unsigned int nEffectDoodad;
		unsigned int ofsSndEmitters; // MCSE
		unsigned int nSndEmitters; // will be set to 0 in the client if ofsSndEmitters doesn't point to MCSE!
		unsigned int ofsLiquid; // MCLQ
		unsigned int sizeLiquid; // 8 when not used; only read if >8.
		float  zpos;
		float  xpos;
		float  ypos;
		unsigned int textureId; // MCCV, only with flags&0x40, had UINT32 textureId; in ObscuR's structure.
		unsigned int props;
		unsigned int effectId;
	}MapChunkHeader;

	typedef struct _map_chunk_layer{
		unsigned int textureId;
		unsigned int flags;
		unsigned int offsetInMCAL;
		short effectId;
		short padding;
	}map_chunk_layer;


	typedef struct _map_chunk_normal{
		char data[3];
	}map_chunk_normal;
}
#endif
